/**
 * @file ring_buffer.h
 * @brief 
 * @author  ()
 * @version 1.0
 * @date 2024-11-04
 * @ingroup hdl
 * @copyright Copyright (C) 2019 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 * 
 * @par 修改日志:
 * <table>
 * <tr><th>Date       <th>Version <th>Author  <th>Description
 * <tr><td>2024-11-04 <td>1.0     <td>     <td>内容
 * </table>
 */
#ifndef _NX_RING_BUFFER_H_
#define _NX_RING_BUFFER_H_

#include <stdint.h>
#include <stdbool.h>

#define MAX_BUFF_SIZE  (4096)               /* the max size of the buffer */
 

#ifdef __cplusplus
extern "C" {
#endif

    
typedef struct 
{
  uint16_t head;                    /* head of the buffer */ 
  uint16_t tail;                    /* tail of the buffer */ 
  uint8_t ringBuf[MAX_BUFF_SIZE + 1];   /* buffer array */
} ringBuffer_t;

uint8_t ringBuf_Write(ringBuffer_t* ring_buff, uint8_t data);

uint8_t ringBuf_Read(ringBuffer_t* ring_buff, unsigned char* pData);

bool ringBuf_is_full(ringBuffer_t* ring_buff);

void ringBuf_clear(ringBuffer_t* ring_buff);

bool ringBuf_is_empty(ringBuffer_t* ring_buff);


#ifdef __cplusplus
}
#endif

#endif
